package com.cn.wanxi.controller;

import com.alibaba.fastjson.JSONObject;
import com.cn.wanxi.entity.UserEntity;
import com.cn.wanxi.service.IUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

@Controller
@RequestMapping("/back/user")
public class UserController {


    @Autowired
    private IUserService iUserService;
    @RequestMapping("/findAll")
    public void findAll(HttpServletResponse response) throws IOException {

        List<UserEntity> list = iUserService.findAll();
        JSONObject jsonObject = new JSONObject();
        jsonObject.put("list", list);
        response.getWriter().println(jsonObject);
    }
    @RequestMapping("/findById")
    public void findById(HttpServletResponse response) throws IOException {

        List<UserEntity> list = iUserService.findAll();
        JSONObject jsonObject = new JSONObject();
        jsonObject.put("list", list);
        response.getWriter().println(jsonObject);
    }
}
